﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>Index</title>

    

    <link href="../../Scripts/ext-4.0.7-gpl/resources/css/ext-all.css" type="text/css"
        rel="Stylesheet" />
    <script src="../../Scripts/ext-4.0.7-gpl/ext-all-debug.js" type="text/javascript"
        language="javascript"></script>

    

    <script type="text/javascript" language="javascript">    


        Ext.namespace('LanWatch');
        Ext.namespace('LanWatch.Util');

        //         /**
        //        * Relays selected events from the specified origin as if the events were fired by `target`.
        //        *
        //        * param {Object} origin The Observable whose events this object is to relay.
        //        * param {String[]} events Array of event names to relay.
        //        * param {String} prefix
        //        */
        function WireEvents(origin, target, targetListener, events, prefix) {
            //debugger;
            console.log('inside WireEvents');
            prefix = prefix || '';
            len = events.length;
            var i, oldName, newName;

            for (i = 0; i < len; i++) {
                oldName = events[i]; //.substr.(prefix.length);
                newName = prefix + oldName;
                target.events[newName] = target.events[newName] || true;
                origin.on(oldName, target.createRelayer(newName));
                target.on(newName, targetListener, target);
            }
        }

        function CreateRelayer(newName) {
            var me = this;
            return function () {
                return me.fireEvent.apply(me, [newName].concat(Array.prototype.slice.call(arguments, 0, -1)));
            };
        }

        function onVProCheckBoxChanged(origin, newVal, oldVal, args) {            
            if (newVal) {
                this.enable();
            }
            else {
                this.disable();
            }
        }
    </script>
    <script type="text/javascript" language="javascript" src="../../Scripts/Schedular/ext-overrides.js"></script> 
    <script type="text/javascript" language="javascript" src="../../Scripts/Schedular/All.js"></script> 
    <script type="text/javascript" language="javascript" src="../../Scripts/Schedular/kaseya-lang-en_US.js"></script> 
    <script type="text/javascript" language="javascript" src="../../Scripts/Schedular/ScheduleHelpers.js"></script> 
    <script type="text/javascript" language="javascript" src="../../Scripts/Schedular/SchedularViewHandlers.js"></script>
    <script src="../../Scripts/Schedular/KScheduler2.js" type="text/javascript" language="javascript"></script>


    <script type="text/javascript" language="javascript">
Ext.namespace('LanWatch');
Ext.namespace('LanWatch.Forms');

//Ext.require('Ext.form.field.CheckBox');

Ext.onReady(function () {
    LanWatch.Forms.FormBaseCls = Ext.extend(Ext.form.Panel, {    
    autoHeight: true,
    frame: true,
    border: true,
    autoScroll: false,
    draggable: false,
    closable: false, 
    bodyStyle: 'padding: 3px',     

    initComponent: function () {        
        LanWatch.Forms.FormBaseCls.superclass.initComponent.call(this);
    }
}); //End of LanWatch.Forms.FormBaseCls.

//Create form items:
var networkName_txt = Ext.create('Ext.form.field.Text', {  
    id: 'networkName_txt',
    qtip: 'Network NickName. It can be string of characters, numbers, or a mix of both.',
    name: 'networkName_txt',
    fieldLabel: 'Network Name',
    labelAlign: 'left',
    labelWidth: 150,
    disabled: false,
    anchor: '95%',
    value: ''       
});

var ipRange_txt = Ext.create('Ext.form.field.Text', {    
    id: 'ipRange_txt',
    name: 'ipRange_txt',
    qtip: 'IP addresses to be scanned. CIDR-style and octet range addressing format are accepted. \n' + 'Examples:  \n' + 
          '192.168.10.0/24 would scan the 256 hosts between 192.168.10.0 and 192.168.10.255. \n' +
          '192.168.3-4.1-254 will scan 192.168.3.0/24, and 192.168.4.0/24.',
    anchor: '95%',
    labelWidth: 150,
    fieldLabel: 'IP Range',                                    
    //disabled: true
 });

 var exclusions_txt = Ext.create('Ext.form.field.Text', {    
    id: 'exclusions_txt',
    name: 'exclusions_txt',
    qtip: 'IP addresses to be excluded. specify a comma-separated list of targets to be excluded from the scan. The list you pass in uses normal Nmap syntax, ' + 
          'so it can include hostnames, CIDR netblocks, octet ranges, etc. \n This can be useful when the network you wish to scan includes untouchable ' +  
          'mission-critical servers, systems that are known to react adversely to port scans, or subnets administered by other people.',
    fieldLabel: 'Exclusions',
    labelWidth: 150,
    anchor: '95%'    
});

var snmpComStr_txt = Ext.create('Ext.form.field.Text', {    
    id: 'snmpComStr_txt',
    name: 'snmpComStr_txt',
    qtip: 'Default is "public"',
    inputType: 'password',
    fieldLabel: 'SNMP Community String',
    value: 'public',
     labelWidth: 150,
    anchor: '95%'                                
});

var snmpComStr_lbl = Ext.create('Ext.form.Label', {
    xtype: 'label',
    id: 'snmpComStr_lbl',
    name: 'snmpComStr_lbl',
    style: {'margin-left': '160px', 'font-size':'xx-small', 'font-effect': 'engrave'},                                
    fieldLabel: '',
    text: 'Default is "public"',
    anchor: '85%'//,                                
});

var vProStatus_checkbox = Ext.create('Ext.form.field.Checkbox', {
    id: 'vProStatus_checkbox',
    name: 'vProStatus_checkbox',    
    fieldLabel: '',
    boxLabel: 'Enable VPro',
    style: 'margin: 3px 0px 3px 0px',
    anchor: '95%'    
});



var vProUserName_txt = new Ext.create('Ext.form.field.Text', {
    id: 'vProUserName_txt',
    name: 'vProUserName_txt',
    fieldLabel: 'User Name',
    labelAlign: 'left',
    labelWidth: 150,
    disabled: true,
    anchor: '95%',
    value: ''    
});

WireEvents(vProStatus_checkbox, vProUserName_txt, onVProCheckBoxChanged, ['change'], 'vproCheckBox_');

var vProPassword_txt = Ext.create('Ext.form.field.Text', {
    id: 'vProPassword_txt',
    name: 'vProPassword_txt',
    inputType: 'password',
    fieldLabel: 'Password',
    labelAlign: 'left',
    labelWidth: 150,
    disabled: true,
    anchor: '95%'    
});

WireEvents(vProStatus_checkbox, vProPassword_txt, onVProCheckBoxChanged, ['change'], 'vproCheckBox_');

var vProPasswordConfirm_txt = Ext.create('Ext.form.field.Text', {
    id: 'vProPasswordConfirm_txt',
    name: 'vProPasswordConfirm_txt',
    inputType: 'password',
    fieldLabel: 'Confirm Password',
    labelAlign: 'left',
    labelWidth: 150,
    disabled: true,
    anchor: '95%'    
});

WireEvents(vProStatus_checkbox, vProPasswordConfirm_txt, onVProCheckBoxChanged, ['change'], 'vproCheckBox_');

var alertStatus_checkbox = Ext.create('Ext.form.field.Checkbox', {
    id: 'alertStatus_checkbox',
    name: 'alertStatus_checkbox',    
    fieldLabel: '',
    boxLabel: 'Enable Alerts',
    style: 'margin: 3px 0px 3px 0px',
    anchor: '95%'    
});

var emailRecipients_txt = Ext.create('Ext.form.field.Text', {
    id: 'emailRecipients_txt',
    name: 'emailRecipients_txt',
    qtip: 'Generate an alert when LAN Watch scan results discover any new device on the LAN.',
    fieldLabel: 'Email Recipients',
    labelAlign: 'left',
    labelWidth: 150,
    disabled: true,
    anchor: '85%',
    value: ''
});

WireEvents(alertStatus_checkbox, emailRecipients_txt, onVProCheckBoxChanged, ['change'], 'alertCheckBox_');

var ignoreDays_txt = Ext.create('Ext.form.field.Text', {
    id: 'ignoreDays_txt',
    name: 'ignoreDays_txt',
    labelAlign: 'left',
    labelWidth: 150,
    qtip: 'Ignore devices the have been seen in the last x days. Set the ignore days to prevent alerts issuing when devices are offline for short periods.',
    fieldLabel: 'Ignore For',
    anchor: '50%',
    disabled: true,
    value: ''    
});

WireEvents(alertStatus_checkbox, ignoreDays_txt, onVProCheckBoxChanged, ['change'], 'alertCheckBox_');

var skipAlert_checkbox = Ext.create('Ext.form.field.Checkbox', {
    labelStyle: '',
    //style: 'margin-left: -105px',
    labelAlign: 'left',
    labelWidth: 150,
    disabled: true,                               
    boxLabel: 'Skip alert if MAC address matches existing agent.' 
});    

WireEvents(alertStatus_checkbox, skipAlert_checkbox, onVProCheckBoxChanged, ['change'], 'alertCheckBox_');   

//Create KSchedular:

var meta = GetMetaString("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
var seedData = GetDataConfig();

//var vsaSchedular = new Kaseya.web.widgets.composite.scheduler.KSchedulerNew();
var vsaSchedular = new Kaseya.web.widgets.composite.scheduler.KSchedulerNew({
    height: 150,
    closeAction: 'hide',
    hourlyInterval: 1,
    dailyInterval: 1,
    weeklyInterval: 1,
    monthlyInterval: 1,
    formReaderRoot: 'records.Scheduler',
    assembled: false,
    metaConfig: meta,
    dataConfig: seedData,
    callbackFunction: 'schedulerSubmitCallback',
    id: 'lanWatchScheduler'
});                   

//Create FieldSets
var networkInformation_fieldset = Ext.create('Ext.form.FieldSet', {
    id: 'networkInformation_fieldset',
    columnWidth: 1,
    title: 'Network Information',
    collapsible: true,            
    autoHeight: true,    
    items: [networkName_txt, ipRange_txt, exclusions_txt, snmpComStr_txt, snmpComStr_lbl]   
});

var vpro_fieldset = Ext.create('Ext.form.FieldSet', {        
    columnWidth: 1,
    title: 'VPro',
    collapsible: true,
    collapsed: true,
    autoHeight: true,              
    items: [vProStatus_checkbox, vProUserName_txt, vProPassword_txt, vProPasswordConfirm_txt]
});

var alerts_fieldSet = Ext.create('Ext.form.FieldSet', {
    columnWidth: 1,
    title: 'Alerts',
    qtip: 'Alert when new devices discovered.',
    collapsible: true,
    collapsed: true,
    autoHeight: true,    
    defaultType: 'textfield',
    items: [alertStatus_checkbox, emailRecipients_txt, ignoreDays_txt, skipAlert_checkbox]
}); 

//var schedule_fieldSet = Ext.create('Ext.form.FieldSet', {
//    id: 'scheduleSettings_fieldset',
//    columnWidth: 1,
//    title: 'Schedule',
//    qtip: '',
//    collapsible: true,
//    collapsed: true,
//    autoHeight: true,    
//    defaultType: 'textfield',
//    items: [vsaSchedular]
//}); 



//WireEvents:
LanWatch.Forms.ProbeConfigForm = Ext.extend(LanWatch.Forms.FormBaseCls, {
    id: 'probeConfig_Form',

     initComponent: function () {        
        LanWatch.Forms.ProbeConfigForm.superclass.initComponent.call(this);
    },

    items: [networkInformation_fieldset, vpro_fieldset, alerts_fieldSet]

   
}); // End of LanWatch.Forms.ProbeConfigForm


 var form = new LanWatch.Forms.ProbeConfigForm();
    

        var win = new Ext.Window({
                    frame: false,
                    border: false,
                    draggable: true,
                    layout: 'fit',
                    closable: true,
                    closeAction: 'hide',
                    buttonAlign: 'center',
                    //autoWidth: true,
                    width: 500,                    
                    autoHeight: true,
                    //height: 700,
                    title: 'Lan Watch: Configure a Probe',
                    buttons: [
                    { id: 'save_btn', name: 'save_btn', text: 'Save', handler: function () { win.onSave(); } },
                    { id: 'cancel_btn', text: 'Cancel', handler: function () { win.hide(); } }],
                    items: [form]
                    });

                    win.show();
});


       
    </script>
</head>
<body>
    <div>
    </div>
</body>
</html>
